<template lang="pug">
  van-datetime-picker(ref="pick" :value="value" type="year-month" @confirm="confirm" @cancel="cancel" :formatter="formatter")
</template>
<script>
// import { addZero } from '../../../../../../../../common/utils/validate'
import _ from 'lodash'

export default {
  name: 'dateRender',
  components: {},
  props: ['config', 'editor', 'value', 'readonly'],
  methods: {
    confirm() {
      let date = this.$refs.pick.$children[0].getValues()
      let dateValue = []
      _.forEach(date, one => {
        dateValue.push(one.slice(0, -1))
      })
      this.$emit('input', dateValue.join('-'))
      this.$emit('popupClose', dateValue.join('-'))
    },
    cancel() {
      this.$emit('popupClose')
    },
    formatter(type, value) {
      if (type === 'year') {
        return `${value}年`
      } else if (type === 'month') {
        return `${value}月`
      } 
      return value
    },
    created() {
    }
  }
}
</script>
<style lang="scss">

</style>
